//
//  validateInputValue.m
//  QRMaster
//
//  Created by myApple on 15/10/16.
//  Copyright (c) 2015年 myApple. All rights reserved.
//

#import "validateInputValue.h"
#import "PromptInfoView.h"

@implementation validateInputValue

//手机号码的判断
+(BOOL)telePhoneValidate:(NSString *)telephone
{

    NSString *passWordRegex = @"^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$";
    NSPredicate *passWordPredicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",passWordRegex];
    return [passWordPredicate evaluateWithObject:telephone];
}

//密码验证
+(BOOL)validatePassword:(NSString *)PassWord
{
    NSString *passWordRegex = @"(?=^[a-zA-Z0-9]{6,20}$).*[a-zA-Z]+.*";
    NSPredicate *passWordPredicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",passWordRegex];
    return [passWordPredicate evaluateWithObject:PassWord];
}

//邮箱验证
+(BOOL)validateEmail:(NSString *)email
{
    if (email.length > 50) {
        return NO;
    }
    //点后面最少两个字符，最多4个字符
    NSString *emailRegex = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
    NSPredicate *emailPredicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",emailRegex];
    return [emailPredicate evaluateWithObject:email];
}

/**
 *  判断是否是电话号码数字
 *
 *
 *  @return yes表示是，no表示不是
 */
+(BOOL)isPureNumandCharacters:(NSString *)string
{
    if (string.length > 11) {
        return NO;
    }
    string = [string stringByTrimmingCharactersInSet:[NSCharacterSet decimalDigitCharacterSet]];
    if(string.length > 0)
    {
        return NO;
    }
    return YES;
}
/**
 *  判断是否为空
 *
 *  @param string 要判断的字符串
 *
 *  @return yes为空  no就不为空
 */
+(BOOL)validateStringIsNull:(NSString *)string
{
    if (string.length == 0) {
        return YES;
    }
    return NO;
}

+(BOOL)validateStringLength:(NSString *)string minLength:(NSInteger)min maxLength:(NSInteger)max
{
    if (string.length < min || string.length > max) {
        return NO;
    }
    return YES;
}

+(BOOL)validateString:(NSString *)companyNoString
{
    NSString * noRegex = @"^[a-zA-Z0-9\\-_]{1,20}$";
    NSPredicate * noPredicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",noRegex];
    return [noPredicate evaluateWithObject:companyNoString];
}

@end
